You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agent-context): save ai_skills before re-registering extensions on init --force - #5323
specify init --here --force into a skills-mode agent re-registered installed extensions before init-options.json recorded ai_skills, so the extension manager rendered command files instead of SKILL.md files.
What changed
src/specify_cli/command_init.py: save the init options (including the ai_skills flag) right after setup() and before the force re-registration, instead of after the shared-infra and workflow steps. The block moved verbatim; all its inputs are already resolved at that point.
How verified
New regression test test_init_force_registers_extensions_as_skills_in_skills_mode fails on main and passes with the fix: after a force re-init into copilot, the extension SKILL.md exists and no command file is written.
ruff check (0.15.0, the CI version) clean on both changed files.
Honest limits: the fix touches no platform-branched code, so no Windows-specific verification was needed; Windows pytest proof awaits CI. Only the init/extension/integration suites ran locally, not the full suite.
…n init --force
`specify init --here --force` into a skills-mode agent re-registered
installed extensions before init-options.json recorded ai_skills, so
the extension manager rendered command files instead of SKILL.md
files. Save the init options right after setup() and before the
force re-registration; the block moved verbatim and all its inputs
are already resolved at that point.
Fixesgithub#5321
…ration
Forced extension skill registration bypasses the pre-existing-directory
guards, so a skill directory that is a symlink to a location outside
the project would receive the generated SKILL.md. Validate the skill
destination against its trusted root before any write, reusing the
shared-infrastructure check that already guards skill removal, and
skip destinations outside any trusted root.
Adds a regression test: a forced re-init with a symlinked extension
skill directory writes nothing outside the project.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Relative project roots can silently skip extension skills, forced registration can modify hard-linked files, and an unguarded symlink test can fail on Windows without symlink privileges.
Prevent forced registration from overwriting hard-linked skill files
src/specify_cli/extensions/__init__.py:1640
The new directory check does not reject an existing hard-linked SKILL.md; forced registration still writes it in place, changing every file linked to the same data. Saving skills options earlier makes this path reachable during force re-init even without previous skills options. Protect the file write as well, by rejecting multiply linked destinations or replacing them without modifying the existing file's data, and add regression coverage.
AI-generated review: GitHub Copilot for the requesting reviewer (identity not supplied; model unknown; automated mode; fully AI-generated).
… SKILL.md on forced registration
Copilot review on github#5323 found three follow-ups to the symlinked-destination fix: relative project roots failed trusted-root validation and silently skipped skills, an existing hard-linked SKILL.md was rewritten in place, and the symlink regression test failed on Windows without symlink privileges.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A failed hard-link detachment still allows an in-place write, which can unintentionally modify other hard-linked copies; the error path must stop the write and have test coverage.
Do not overwrite hard-linked files when detaching fails
src/specify_cli/extensions/__init__.py:1743
If detaching the hard link raises OSError, this handler still reaches write_text, which uses an in-place Path.write_text. For example, a writable file in a non-writable directory can be overwritten even though it cannot be unlinked, so other hard-linked copies are still modified—the behavior this guard is intended to prevent. Skip the skill or propagate the error rather than proceeding, and add coverage for a failed detach.
AI-generated review for the requester by GitHub Copilot (model unknown; automated mode; code-review analysis).
…egistration
A failed hard-link detach still fell through to the in-place write, so a
writable SKILL.md in a non-writable directory was overwritten through the
surviving link and every linked copy changed. Skip the skill instead and
leave the file untouched; the init itself still succeeds.
Adds a regression test that fails the detach and checks both the linked
copy outside the project and the project skill keep their old content.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed to assess unpublished findings involving a critical Windows junction overwrite risk and incomplete skill registration during generic force-init.
All of the Copilot feedback here is already addressed on this branch:
Symlinked skill destinations are rejected before any write, in 56b903c.
Relative project roots are normalized to an absolute path before validation in 7d09da6, so skills are no longer silently skipped, and the symlink test now skips on Windows accounts without symlink privileges.
A failed hard-link detach now skips the skill instead of writing through it, in ae748e5.
The later Copilot review links back to the same symlink finding, which 56b903c already covers.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The destination validator still accepts in-root Windows directory junctions, allowing forced extension registration to overwrite another directory’s existing SKILL.md.
Please address Copilot feedback. If not applicable, please explain why
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triage-must-haveVerdict: high-value, important work for Spec Kit — do first
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5321
What broke
specify init --here --forceinto a skills-mode agent re-registered installed extensions before init-options.json recorded ai_skills, so the extension manager rendered command files instead of SKILL.md files.What changed
src/specify_cli/command_init.py: save the init options (including the ai_skills flag) right after setup() and before the force re-registration, instead of after the shared-infra and workflow steps. The block moved verbatim; all its inputs are already resolved at that point.How verified
test_init_force_registers_extensions_as_skills_in_skills_modefails on main and passes with the fix: after a force re-init into copilot, the extension SKILL.md exists and no command file is written.tests/specify_cli/test_command_init.py25/25, extension skills + upgrade + bundles suites 187/187, integration generic/cli suites 318/318.ruff check(0.15.0, the CI version) clean on both changed files.